package com.BaiBai.advice;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

import java.util.Arrays;


//@Component
//@Aspect
public class MyAdvice {

    @Before("com.BaiBai.pointcut.MyPointcut.pc()")
    public void before(JoinPoint joinPoint) {
        String simpleName = joinPoint.getTarget().getClass().getSimpleName();
        System.out.println(simpleName);
        //获取方法名称
        String methodName = joinPoint.getSignature().getName();
        System.out.println(methodName);
        //获取参数列表
        Object[] args = joinPoint.getArgs();
        System.out.println(Arrays.toString(args));
    }
    @AfterReturning(value = "com.BaiBai.pointcut.MyPointcut.pc()",returning = "result")
    public void after(Object result) {

    }
    @AfterThrowing(value = "com.BaiBai.pointcut.MyPointcut.pc()",throwing = "throwable")
    public void afterThrowing(Throwable throwable) {

    }
}
